import { post, get } from '@/utils/request'

// https://www.byteverse.vip/

export function login<T>(data: { password: string; username: string }) {
  return post<T>({
    url: '/api/user/login?turnstile=',
    data,
  })
}

export function wechatLogin<T>(data: { code: string }) {
  return get<T>({
    url: '/api/oauth/wechat',
    data,
  })
}


export function fetchSelf<T>() {
  return get<T>({
    url: '/api/user/self',
  })
}

export function fetchSendEmailVerify<T>(data: { email: string }) {
  return get<T>({
    url: '/api/verification?turnstile=',
    data,
  })
}

export function fetchRegister<T>(data: { verification_code: string; username: string; aff_code: string; email: string; password: string; password2: string }) {
  return post<T>({
    url: '/api/user/register?turnstile=',
    data,
  })
}

export function fetchAff<T>() {
  return get<T>({
    url: '/api/user/aff',
  })
}




// --------------------------------------- //
export function fetchLog<T>(data: { p: string; page_size: string; type: string; token_name: string; model_name: string; start_timestamp: string; end_timestamp: string }) {
  return get<T>({
    url: '/api/log/self',
    data,
  })
}

export function fetchLogStat<T>(data: { type: string; token_name: string; model_name: string; start_timestamp: string; end_timestamp: string }) {
  return get<T>({
    url: '/api/log/self/stat',
    data,
  })
}


export function fetchTopup<T>(data: { key: string; }) {
  return post<T>({
    url: '/api/user/topup',
    data,
  })
}

// 缺一个公告接口...
export function fetchNotice<T>() {
  return get<T>({
    url: '/api/notice',
  })
}

export function fetchGlobalStatus<T>() {
  return get<T>({
    url: '/api/status',
  })
}

export function fetchPay<T>(data: { amount: number; payment_method: string;  top_up_code: string}) {
  return post<T>({
    url: '/api/user/pay',
    data,
  })
}